package org.gdpu.service.impl;

import org.gdpu.base.DaoSupport;
import org.gdpu.model.Examination;
import org.gdpu.model.Examiner;
import org.gdpu.model.Person;
import org.gdpu.model.Subject;
import org.gdpu.service.ExaminerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.Query;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-4
 * Time: 下午1:01
 * To change this template use File | Settings | File Templates.
 */
@Service
@Transactional
public class ExaminerServiceImpl extends DaoSupport<Examiner> implements ExaminerService {

    @Override
    public Examiner findExaminer(Subject subject,Person studentID){
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("subject", subject);
        params.put("studentID", studentID);
        return (Examiner) this.findSpecialObject(Examiner.class, params);
    }

    @Override
    public Examiner findExaminerByAccout(Person studentID,Examination examination){
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("studentID", studentID);
        params.put("examination", examination);
        return (Examiner) this.findSpecialObject(Examiner.class, params);
    }

    @Override
    public List<Examiner> allExaminer() {
        Query query = em.createQuery("from Examiner e");
        return query.getResultList();
    }
}
